/*lic*/
#ifndef __BUF_DEF_H__
#define __BUF_DEF_H__
#include <stdint.h>
#include <rtthread.h>
#include "main.h"

#include "BaseDef.h"

// 定义系统状态
#define SYS_LOG_OK 0x01 // 系统日志系统已被初始化

// 定义基础内存池
extern struct rt_mempool sdram1_mp;

// 串口9 RS485-3接收信号
extern rt_sem_t rs485_3_usart_tx_sem;
extern rt_sem_t rs485_3_usart_rx_sem;
// rs495-3接收邮箱
extern struct rt_messagequeue rs485_3_usart_rx_mq;

// 配置文件结构体
typedef struct __Tag_Config_Map_Def {
	char key[32];
	char value[256];
} Config_Map_Def;

#define CONFIG_ARRAY_SIZE 10
extern const Config_Map_Def device_address[CONFIG_ARRAY_SIZE];

// 宏定义区 这里指定各个缓冲区的功能名
// 调试串口
#define debug_rx_msg_pool usart_3_rx_msq_pool
#define debug_rx_msg_buf usart_3_tx_msq_buf

// RT485-1串口
#define rs485_rx_size u2_rx_size
// 应用侧缓冲区
#define rs485_1_rx_app_buf usart_2_rx_app_buf
#define rs485_1_tx_app_buf usart_2_tx_app_buf
// 外设侧缓冲区
#define rs485_1_rx_msq_buf usart_2_rx_msq_buf
#define rs485_1_rx_msq_buf usart_2_rx_msq_buf
// 邮箱内存池
#define rs485_1_rx_msq_pool usart_2_rx_msq_pool
#define rs485_1_tx_msq_pool usart_2_tx_msq_pool

// RS485-2 串口
#define rs485_2_rx_app_buf usart_6_rx_app_buf
#define rs485_2_tx_app_buf usart_6_tx_app_buf
#define rs485_2_rx_msq_buf usart_6_rx_msq_buf
#define rs485_2_rx_msq_buf usart_6_rx_msq_buf
#define rs485_2_rx_msq_pool usart_6_rx_msq_pool
#define rs485_2_tx_msq_pool usart_6_tx_msq_pool

// RS485-3 串口
#define rs485_3_rx_app_buf usart_9_rx_app_buf
#define rs485_3_tx_app_buf usart_9_tx_app_buf
#define rs485_3_rx_msq_buf usart_9_rx_msq_buf
#define rs485_3_rx_msq_buf usart_9_rx_msq_buf
#define rs485_3_rx_msq_pool usart_9_rx_msq_pool
#define rs485_3_tx_msq_pool usart_9_tx_msq_pool


// 串口接收计数器
extern uint32_t u1_rx_size;
extern uint32_t u2_rx_size;
extern uint32_t u6_rx_size;
extern uint32_t u9_rx_size;
// 系统状态标志位
extern uint8_t sys_status;
// mqtt客户端ID
extern char mqtt_client_id[32];

// SDRAM1 128K
// 串口处理缓冲区
extern rt_uint8_t usart_1_rx_app_buf[1024];
extern rt_uint8_t usart_1_tx_app_buf[1024];
extern rt_uint8_t usart_2_rx_app_buf[1024];
extern rt_uint8_t usart_2_tx_app_buf[1024];
extern rt_uint8_t usart_6_rx_app_buf[1024];
extern rt_uint8_t usart_6_tx_app_buf[1024];
extern rt_uint8_t usart_9_rx_app_buf[1024];
extern rt_uint8_t usart_9_tx_app_buf[1024];
// 串口外设缓冲区 
extern __IO rt_uint8_t usart_1_rx_msq_buf[1024]; //*
extern __IO rt_uint8_t usart_1_tx_msq_buf[1024]; //*
extern __IO rt_uint8_t usart_2_rx_msq_buf[1024]; //*
extern __IO rt_uint8_t usart_2_tx_msq_buf[1024]; //*
extern __IO rt_uint8_t usart_6_rx_msq_buf[1024]; //*
extern __IO rt_uint8_t usart_6_tx_msq_buf[1024]; //*
extern __IO rt_uint8_t usart_9_rx_msq_buf[1024]; //*
extern __IO rt_uint8_t usart_9_tx_msq_buf[1024]; //*

// 串口邮箱缓冲区 
extern rt_uint8_t usart_1_rx_msq_pool[4096]; // 4长度内存池
extern rt_uint8_t usart_1_tx_msq_pool[4096];
extern rt_uint8_t usart_2_rx_msq_pool[4096];
extern rt_uint8_t usart_2_tx_msq_pool[4096];
extern rt_uint8_t usart_6_rx_msq_pool[4096];
extern rt_uint8_t usart_6_tx_msq_pool[4096];
extern rt_uint8_t usart_9_rx_msq_pool[4096];
extern rt_uint8_t usart_9_tx_msq_pool[4096];
// 控制台邮箱收发缓冲区
extern rt_uint8_t usart_3_rx_msq_pool[15360]; // 10长度内存池
// rx不需要缓冲区。这里给别的功能用
extern __IO rt_uint8_t usart_3_tx_msq_buf[1536];

// 这里剩下4字节 0x20011FFC
extern __IO rt_uint32_t crc_buf;

/** SPI缓冲区
*
*/
//// FLASH缓冲区
//extern __IO rt_uint8_t spi1_cache[8208];

//// 锐能微缓冲区
//extern __IO rt_uint8_t spi3_cache[4][4];

//// 录波缓冲区
//extern __IO rt_uint8_t spi5_cache[2][4096];
/* SPI缓冲区 */


#endif /* __BUF_DEF_H__ */

/*eof*/
